Skip to content

test(security): Enhance username normalization coverage in TrackUserProtection APIs - #8984

Merged
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
Rakshak05:issue-#6648
Aug 13, 2026
Merged

test(security): Enhance username normalization coverage in TrackUserProtection APIs#8984
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
Rakshak05:issue-#6648

Conversation

@Rakshak05

Copy link
Copy Markdown
Contributor

Description

Fixes #6648

Adds a dedicated unit test suite for username normalization across all public TrackUserProtection APIs (validateFormat, recordWrite, isWriteAllowed, and verifyAndDeduplicate).

Key test scenarios added:

  • Verification that leading and trailing whitespace is ignored.
  • Verification that usernames are treated case-insensitively.
  • Verification that recordWrite(), isWriteAllowed(), and verifyAndDeduplicate() behave consistently for normalized usernames.
  • Verification that equivalent usernames (e.g., OctoCat, octocat, OCTOCAT) reference the same internal entry and reset uniformly.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A (Backend unit tests)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

Copilot AI lite review requested due to automatic review settings August 10, 2026 05:23
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@Rakshak05 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@retenta-bot

retenta-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

This pull request introduces important unit tests for username normalization, which is crucial for maintaining data integrity across the TrackUserProtection APIs. Similar past decisions have focused on adding tests for timezone normalization and calendar boundary handling, emphasizing the importance of thorough testing in ensuring consistent application behavior. It's great to see this proactive approach to testing! If you have any questions or need further assistance, feel free to reach out. Happy coding!

@retenta-bot retenta-bot Bot changed the title test(security): add coverage for username normalization across TrackUserProtection APIs (#6648) test(security): Enhance username normalization coverage in TrackUserProtection APIs Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4998.89 KB 4998.89 KB 0 B
Total CSS 354.18 KB 354.18 KB 0 B

@github-actions github-actions Bot added the type:testing Adding, updating, or fixing tests label Aug 12, 2026
@Aamod007 Aamod007 added mentor:Aamod007 type:security Security fixes, dependency updates, or hardening level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Aug 13, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on expanding our test suite! The added scenarios in \ rack-user-protection.username-normalization.test.ts\ perfectly capture the critical edge cases for username normalization, specifically verifying whitespace trimming and case-insensitivity.

Validating that equivalent usernames refer to the same internal entry is crucial for ensuring our rate limits cannot be bypassed.

Labels applied:

  • type:testing, type:security: Adds security-focused unit tests for rate limiting logic.
  • level:beginner: Clear and straightforward test suite additions.
  • quality:clean: Well-structured tests that thoroughly cover the specifications.

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Aug 13, 2026
@JhaSourav07
JhaSourav07 merged commit ccbb991 into JhaSourav07:main Aug 13, 2026
10 of 11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @Rakshak05! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@github-actions github-actions Bot added this to the GSSoC 2026 milestone Aug 13, 2026
@Rakshak05
Rakshak05 deleted the issue-#6648 branch August 13, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:security Security fixes, dependency updates, or hardening type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] Add coverage for username normalization across TrackUserProtection APIs

4 participants